package com.zbs.simbot.data.mysuser;

import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class MysCookie {

    /**
     * cookie_token
     */
    private String cookieToken;

    /**
     * token
     */
    private String token;

    /**
     * 通行证ID
     */
    private String tuid;

    /**
     * mid
     */
    private String mid;
    /**
     * 绑定的QQ
     */
    private Long qq;



    public MysCookie(Long qq, JSONObject gameTokenRespJson, JSONObject cookieRespJson) {
        this.cookieToken = cookieRespJson.getJSONObject("data").getString("cookie_token");
        this.token = gameTokenRespJson.getJSONObject("data").getJSONObject("token").getString("token");
        this.tuid = gameTokenRespJson.getJSONObject("data").getJSONObject("user_info").getString("aid");
        this.mid = gameTokenRespJson.getJSONObject("data").getJSONObject("user_info").getString("mid");;
    }

    public String getCookies() {
        return String.format("ltoken=%s;ltuid=%s;cookie_token=%s;account_id=%s", token, tuid, cookieToken,tuid);
    }

    public String getSToken() {
        return String.format("stoken=%s;stuid=%s;mid=%s", token, tuid, mid);
    }

}
